
// For compilers that support precompilation, includes "wx/wx.h".
#include "wx/wxprec.h"

#ifdef __BORLANDC__
    #pragma hdrstop
#endif

// for all others, include the necessary headers (this file is usually all you
// need because it includes almost all "standard" wxWidgets headers)
#ifndef WX_PRECOMP
    #include "wx/wx.h"
#endif

#include "DCircle.h"

DCircle::DCircle(void)
{
}

DCircle::DCircle(wxString *str)
{

}


DCircle::~DCircle(void)
{
}

void DCircle::Draw(wxDC *dc)
{
	if(m_selected == TRUE)
	{
		this->SetDrawingTools(dc);
		dc->SetPen(wxPen(wxColor(0, 0, 255), 1, wxDOT));
		dc->DrawCircle(m_position, this->m_radius);
	}
	else
	{
		this->SetDrawingTools(dc);
		dc->DrawCircle(m_position, this->m_radius);
	}
}

bool DCircle::PointInside(wxPoint *pnt)
{
	float distance = sqrt(pow((float)(pnt->x - this->m_position.x), 2) + pow((float)(pnt->y - this->m_position.y), 2));

	int rad = 0;
	if(m_radius < 0)
		rad = -m_radius;
	else
		rad = m_radius;

	if(distance <= (float)rad)
		return TRUE;
	else
		return FALSE;
}

float DCircle::GetArea()
{
	return this->m_radius * this->m_radius * 3.1415192f;
}

void DCircle::ConvertToText(wxString *str)
{
	*str << wxT("circle\t") << this->m_position.x << wxT("\t") << m_position.y << wxT("\t") << this->m_radius << wxT("\n");
}

wxPoint DCircle::GetTopLeft(void)
{
	return wxPoint(this->m_position.x - this->m_radius, this->m_position.y - m_radius);
}

wxPoint DCircle::GetBottomRight()
{
	return wxPoint(this->m_position.x + this->m_radius, this->m_position.y + m_radius);
}